import { ProColumns, ProTable } from '@ant-design/pro-components';
import '@umijs/max';
import { Modal } from 'antd';
import React from 'react';

export type FormValueType = {
  target?: string;
  template?: string;
  type?: string;
  time?: string;
  frequency?: string;
} & Partial<API.RuleListItem>;

export type Propers = {
  columns: ProColumns<API.InterfanceInfo>[];
  onCancel: () => void; //关闭方法
  onSubmit: (value: API.InterfanceInfoAddRequest) => Promise<void>; // 提交方法
  visible: boolean;
};
const CreateForm: React.FC<Propers> = (props) => {
  const { columns, visible, onCancel, onSubmit } = props;

  return (
    <Modal
      visible={visible}
      onCancel={() => {
        console.log('执行cancle方法');
        onCancel?.();
      }}
    >
      <ProTable<API.InterfanceInfo>
        type={'form'}
        columns={columns}
        rowKey="id"
        key={'createForm.Protable'}
        onSubmit={(value: API.InterfanceInfoAddRequest) => {
          console.log('执行submit方法');
          onSubmit?.(value);
        }}
      />
    </Modal>
  );
};

export default CreateForm;
